#ifndef _DSWOSD_H
#define _DSWOSD_H
#include <libbase/dswbase.h>
#include <libdswfontcvt/dswfontcvt.h>

class CDswosd : public CDswbase
{
public:
	CDswosd(LPST_ENV_T pEnv, void* pCapture, void* pBindfd, int nCh, gm_palette_table_t *pPalette);
	virtual ~CDswosd();
public:
	void ShowTextOsd(char* pText, bool bShow);
private:
	static void cbOsdTask(int fd, short events, void* ctx){((CDswosd*)ctx)->OsdTask(fd, events);};
	void OsdTask(int fd, short events);
	void UpdateTimeOsd(time_t nNow, bool bShow);

	static void cbUpdateOSDPaletteTask(int fd, short events, void* ctx){((CDswosd*)ctx)->UpdateOSDPaletteTask(fd, events);};
	void UpdateOSDPaletteTask(int fd, short events);
	bool GetBackgroundYUV(int nX, int nY, int &nYUV_F, int &nYUV_B);

	int UpdateOsdFont(char* pOsdText, bool bTimeOsd);

	void CreateNoSignalOSD();
	void ShowNoSignalOSD(bool bShow);
	void CheckSignal();
protected:
	virtual int OnMessage(EN_MSG_TYPE nMsgType, void * pParam);
private:
	void *m_pCapture, *m_pBindfd;
	int m_nChId;
	time_t m_nOldTime;
	ST_TIMER_PARAM_T m_nOsdTask, m_nOsdPaletteTask;
	char m_sOsdText[128], m_sLastWin0[32], m_sLastWin1[32], m_sLastWin2[32];
	bool m_bShowTm, m_bShowTxt;
	char* m_pYUVBuffer;
	CDswfontcvt* m_pFontCvt;
	gm_palette_table_t *m_pPalette;

	unsigned short* m_pNoSignalFont;
	ST_SIGNAL_T m_nSignal;
};

#endif

